#python modules
import logging
import os
import datetime

#web modules
import webapp2
import jinja2

#google modules
from google.appengine.api import users

#application modules
from config import config

# This controller handles the
# generation of the front page.
jinja_environment = jinja2.Environment(autoescape=True,loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), '../views')))


class MainHandler(webapp2.RequestHandler):
    def get(self):
        user = users.get_current_user()
        system_date = datetime.datetime.now().strftime("%d-%m-%Y")
        
        # We are using the template module to output the page.
        template = jinja_environment.get_template('main.html')		
        template_values = {'username':user.nickname(),
                           'url': users.create_logout_url("/"),
                           'system_date':system_date
                           }
        self.response.out.write(template.render(template_values))


class AboutHandler(webapp2.RequestHandler):
    def get(self):
        user = users.get_current_user()
        system_date = datetime.datetime.now().strftime("%d-%m-%Y")
        
        # We are using the template module to output the page.
        template = jinja_environment.get_template('about.html')		
        template_values = {'username':user.nickname(),
                           'url': users.create_logout_url("/"),
                           'system_date':system_date
                           }
        self.response.out.write(template.render(template_values))
